package com.PlantVsZombies.game;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

import com.PlantVsZombies.constant.GameVariable;
import com.PlantVsZombies.util.MusicPlay;
import com.PlantVsZombies.util.MusicUtil;

public class Menu extends JPanel {
	static Boolean flag = false;// 点击“帮助”后画出图片
	static Boolean flag1 = false;
	public static Color color = Color.BLACK;
	public static Color color1 = Color.BLACK;
	public static Color color2 = Color.BLACK;
	public static BufferedImage image1;
	public static BufferedImage image2;
	public static BufferedImage image3;
	private static BufferedImage surface;
	public static BufferedImage doubi, doubi_1;
	public static BufferedImage risk, risk_1;
	public static BufferedImage fight, fight_1;
	public static BufferedImage help_1;
	public static BufferedImage diao;
	private static ImageIcon dave;

	static {
		try {
			surface = ImageIO.read(new File("images/login/Surface.png"));
			help_1 = ImageIO.read(new File("images/login/help_1.png"));
			doubi = ImageIO.read(new File("images/login/doubi.png"));
			risk = ImageIO.read(new File("images/login/maoxian.png"));
			risk_1 = ImageIO.read(new File("images/login/maoxian_1.png"));
			doubi_1 = ImageIO.read(new File("images/login/doubi_1.png"));
			dave = new ImageIcon("images/login/Dave3.gif");
			diao = ImageIO.read(new File("images/login/diao.png"));
			fight = ImageIO.read(new File("images/login/fight.png"));
			fight_1 = ImageIO.read(new File("images/login/fight_1.png"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void paint(Graphics g) {
		super.paint(g);
		// 背景
		g.drawImage(surface, 0, 0, null);
		g.drawImage(dave.getImage(), 0, 100, this);
		// 三个小图标
		g.setColor(color);
		g.setFont(new Font("宋体", Font.BOLD, 20));
		g.drawString("关卡设置", 645, 510);
		g.setFont(new Font("宋体", Font.BOLD, 25));
		g.setColor(color1);
		g.drawString("帮助", 730, 540);
		g.setColor(color2);
		g.drawString("退出", 810, 530);
		// 游戏三种模式
		g.drawImage(image1, 470, 60, null);
		g.drawImage(image2, 470, 195, 314, 120, null);
		g.drawImage(image3, 470, 300, 284, 120, null);
		if (flag)
			g.drawImage(help_1, 200, 100, null);
		// 显示玩家信息
		g.drawString("欢迎你，" + GameVariable.player, 20, 50);
	}

	public static MusicPlay menu;

	public Menu() {
		// 对图片进行初始化
		image1 = risk;
		image2 = doubi;
		image3 = fight;
		menu = new MusicPlay(MusicUtil.MENU);
		// 为面板添加事件监听
		this.addMouseListener(new MenuListner());
		this.addMouseMotionListener(new MenuListner());
		// 线程 重绘面板

	}

}
